﻿using B.T.BasicData.ErrorCode;
using B.T.BasicData.Read.Api.DTOs;
using B.T.BasicData.Read.Api.RBACServices.IServices;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.T.BasicData.Read.Api.Controllers
{
    /// <summary>
    ///角色信息管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RolesController : ControllerBase
    {
        private readonly ILogger<RolesController> logger;
        private readonly IRoleServices roleServices;

        public RolesController(ILogger<RolesController> logger,IRoleServices roleServices)
        {
            this.logger = logger;
            this.roleServices = roleServices;
        }

        /// <summary>
        /// 查找角色信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        [Authorize]
        public async Task<ApiPaging<RolePermissionDto>> SraechRole([FromQuery]SraechRoleDto dto)
        {
            try
            {
                return await roleServices.SraechRole(dto);
            }
            catch (Exception ex)
            {

                logger.LogError("=>" + ex.Message);
                throw ex;
            }
        }
    }
}
